﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;

/// <summary>
///DateTimeBetweenSearchShow 的摘要说明
/// </summary>
public class DateTimeBetweenSearchShow:BaseSearchShow
{
	public DateTimeBetweenSearchShow()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    #region ISearchTypeField 成员

    //public IEnumerable<Control> GetSearchFieldControls(ConfigColumns cCol)
    //{
    //    Panel p = new Panel();
    //    Literal lit = new Literal();
    //    lit.Text = cCol.SearchShowName;
    //    p.Controls.Add(lit);

    //    DatePicker min = new DatePicker();
    //    min.ID = cCol.ColumnName + "_SearchShow_min";
    //    min.ValidationGroup = "Search";        
    //    p.Controls.Add(min);

    //    DatePicker max = new DatePicker();
    //    max.ID = cCol.ColumnName + "_SearchShow_max";
    //    max.ValidationGroup = "Search";        
    //    p.Controls.Add(max);

    //    Literal to = new Literal();
    //    to.ID = cCol.ColumnName + "_tolit";
    //    to.Text = " - ";

    //    p.Controls.Add(min);
    //    p.Controls.Add(to);
    //    p.Controls.Add(max);

    //    yield return p;
    //}

    #endregion

    protected override IEnumerable<Control> GetSearchContrls(ConfigColumns cCol)
    {
        DatePicker min = new DatePicker();
        min.ID = cCol.ColumnName + "_SearchShow_min";
        min.ValidationGroup = "Search";

        Page page = HttpContext.Current.Handler as Page;
        if (page != null && page.IsPostBack)
        {
            string requestValueMin = HttpContext.Current.Request[cCol.ColumnName + "_SearchShow_min"];
            if (!string.IsNullOrEmpty(requestValueMin))
            {
                min.Text = requestValueMin;
            }
        }
        yield return min;

        Literal to = new Literal();
        to.ID = cCol.ColumnName + "_tolit";
        to.Text = " - ";
        yield return to;

        DatePicker max = new DatePicker();
        max.ID = cCol.ColumnName + "_SearchShow_max";
        max.ValidationGroup = "Search";
                
        if (page != null && page.IsPostBack)
        {
            string requestValueMax = HttpContext.Current.Request[cCol.ColumnName + "_SearchShow_max"];
            if (!string.IsNullOrEmpty(requestValueMax))
            {
                max.Text = requestValueMax;
            }
        }

        yield return max;
    }
}
